## Prevent character encoding issues from server overrides
## If you still have problems, use the second line instead

    AddDefaultCharset Off
    #AddDefaultCharset UTF-8

# ------------------------------------------------------------------------------
# | Expires headers (for better cache control)                                 |
# ------------------------------------------------------------------------------

# The following expires headers are set pretty far in the future. If you don't
# control versioning with filename-based cache busting, consider lowering the
# cache time for resources like CSS and JS to something like 1 week.

<IfModule mod_expires.c>

    ExpiresActive on
    ExpiresDefault                                      "access plus 1 month"

  # CSS
    ExpiresByType text/css                              "access plus 1 week"

  # Data interchange
    ExpiresByType application/json                      "access plus 0 seconds"
    ExpiresByType application/xml                       "access plus 0 seconds"
    ExpiresByType text/xml                              "access plus 0 seconds"

  # Favicon (cannot be renamed!)
    ExpiresByType image/x-icon                          "access plus 1 week"

  # HTML components (HTCs)
    ExpiresByType text/x-component                      "access plus 1 month"

  # HTML
    ExpiresByType text/html                             "access plus 0 seconds"

  # JavaScript
    ExpiresByType application/javascript                "access plus 1 week"

  # Manifest files
    ExpiresByType application/x-web-app-manifest+json   "access plus 0 seconds"
    ExpiresByType text/cache-manifest                   "access plus 0 seconds"

  # Media
    ExpiresByType audio/ogg                             "access plus 1 month"
    ExpiresByType image/gif                             "access plus 1 month"
    ExpiresByType image/jpeg                            "access plus 1 month"
    ExpiresByType image/png                             "access plus 1 month"
    ExpiresByType video/mp4                             "access plus 1 month"
    ExpiresByType video/ogg                             "access plus 1 month"
    ExpiresByType video/webm                            "access plus 1 month"

  # Web feeds
    ExpiresByType application/atom+xml                  "access plus 1 hour"
    ExpiresByType application/rss+xml                   "access plus 1 hour"

  # Web fonts
    ExpiresByType application/font-woff                 "access plus 1 year"
    ExpiresByType application/vnd.ms-fontobject         "access plus 1 year"
    ExpiresByType application/x-font-ttf                "access plus 1 year"
    ExpiresByType font/opentype                         "access plus 1 year"
    ExpiresByType image/svg+xml                         "access plus 1 year"

</IfModule>

<ifModule mod_headers.c>

	# Paramètres par défaut (1 mois)
	ExpiresActive On
	ExpiresDefault A24192000

	# Polices : 1 an
	<filesMatch ".(woff|ttf|otf)$">
		ExpiresDefault A29030400
		Header append Cache-Control "public"
	</filesMatch>

	# Images : 1 mois
	<filesMatch ".(ico|gif|jpg|jpeg|png|flv|pdf|swf|mov|mp3|wmv|ppt)$">
		ExpiresDefault A2419200
		Header append Cache-Control "public"
	</filesMatch>

	# Mise en page : 1 semaine
	<filesMatch ".(js|css)$">
		ExpiresDefault A604800
		Header append Cache-Control "private, must-revalidate"
	</filesMatch>

	# Flux RSS : 1 heure
	<filesMatch ".(rss|atom)$">
		ExpiresDefault A3600
		Header append Cache-Control "private, must-revalidate"
	</filesMatch>

	# Force no caching for dynamic files
	<filesMatch ".(html|php|cgi|pl)$">
		ExpiresDefault A0
		Header set Cache-Control "no-store, no-cache, must-revalidate, max-age=0"
		Header set Pragma "no-cache"
	</filesMatch>

</ifModule>

# MOD_DEFLATE COMPRESSION
SetOutputFilter DEFLATE
AddOutputFilterByType DEFLATE text/html text/css text/plain text/xml application/x-javascript application/x-httpd-php image/jpeg image/jpg
#Pour les navigateurs incompatibles
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
#ne pas mettre en cache si ces fichiers le sont déjà
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip
#les proxies doivent donner le bon contenu
Header append Vary User-Agent env=!dont-vary

# protect the htaccess file
<files .htaccess>
order allow,deny
deny from all
</files>

<IfModule mod_rewrite.c>
    RewriteEngine On

    <IfModule mod_vhost_alias.c>
        RewriteBase /
    </IfModule>

    # Conservation des fichiers de validation Google
    RewriteCond %{HTTP_HOST}   ^(www\.)?ambroise\.me [NC,AND]
    RewriteCond %{REQUEST_URI}   ^/google([0-9a-f])+\.html [NC]
    RewriteRule ^google([0-9a-f])+\.html$ - [L]

    # Redirection des noms de domaine alternatifs
    RewriteCond %{HTTP_HOST}   ^[^(www)]+\.ambroise\.paris [NC,OR]
    RewriteCond %{HTTP_HOST}   ^(www\.)?ambroise\.name [NC]
    RewriteRule ^/?(.*)         http://www.ambroise\.me/$1 [QSA,L,R=301]

    # Redirection vers un contrôleur frontal
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
